import TbColumn from "@/components/table/tbColumn";
import { TABLE_ENUM } from "@/components/table/enum";
import { formatPercentage, isNull } from "@/utils/service";

/** 将表格值转为百分比*/
function valueToPercentage(row, column, cellValue, index) {
  return !isNull(cellValue) ? formatPercentage(cellValue) : "-";
}

export const COLUMNS = [
  new TbColumn("店铺名称", "storeName", { width: 200 }),
  new TbColumn("流量来源", "trafficsSource", { width: 200 }),
  new TbColumn("数据周期", "dataCycle", { width: 200 }),
  new TbColumn("商品标题", "productTitle", { width: 200 }),
  new TbColumn("商品编号", "productId", { width: 150 }),
  new TbColumn("访客数", "visitorNum", {
    width: 110,
    sortable: true,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("下单买家数", "buyersNum", {
    width: 140,
    sortable: true,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("下单转化率", "orderCvsRate", {
    width: 140,
    sortable: true,
    formatter: valueToPercentage,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.PERCENTAGE_SCOPE
  }),
  new TbColumn("浏览量", "pageView", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("浏览量占比", "percentageOfPageViews", {
    width: 140,
    sortable: true,
    formatter: valueToPercentage,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.PERCENTAGE_SCOPE
  }),
  new TbColumn("店内跳转人数", "inStoreJump", {
    width: 150, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("跳出店铺人数", "outStoreJump", {
    width: 150, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("收藏人数", "collectorNum", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("收藏率", "collectionRate", {
    width: 110,
    sortable: true,
    formatter: valueToPercentage,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.PERCENTAGE_SCOPE
  }),
  new TbColumn("加购人数", "additionalPurchase", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("加购率", "additionRate", {
    width: 110,
    sortable: true,
    formatter: valueToPercentage,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.PERCENTAGE_SCOPE
  }),
  new TbColumn("支付件数", "payoutsNum", {
    width: 120, sortable: true,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("支付买家数", "paidBuyersNum", {
    width: 140, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("支付金额", "amountPaid", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("支付转化率", "payCvsRate", {
    width: 140,
    sortable: true,
    formatter: valueToPercentage,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.PERCENTAGE_SCOPE
  }),
  new TbColumn("直接支付买家数", "directPayBuyersNum", {
    width: 160, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("收藏后支付买家数", "payAfterCollectionBuyersNum", {
    width: 200,
    sortable: true,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("粉丝支付买家数", "payAfterAttentionBuyersNum", {
    width: 160, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("加购商品", "buyMoreBuyersNum", {
    width: 200, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("客单价", "perCustomer", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("uv价值", "uvValue", {
    width: 120, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.INTEGER_SCOPE
  }),
  new TbColumn("创建时间", "createTime", {
    width: 180,
    sortable: true,
    filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.DATE_SCOPE
  }),
  new TbColumn("修改时间", "updateTime", {
    width: 180, sortable: true, filterAble: true,
    filterMode: TABLE_ENUM.FilterModeEnum.DATE_SCOPE
  })
];